
from apis.base_api import BaseApi


class Goods(BaseApi):

    def goods_create(self, goods_data):
        url = "admin/goods/create"

        # r = requests.post(url, json=goods_data, headers={"x-litemall-admin-token": self.token})
        r = self.send("post", url, json=goods_data)
        return r

    def goods_list(self, goods_name, sort='add_time', oder='desc'):
        url = "admin/goods/list"
        parm = {
            'name': goods_name,
            'sort': sort,
            'oder': oder
        }
        # r = requests.get(url, params=parm, headers={"x-litemall-admin-token": self.token})
        r = self.send("get", url, params=parm)
        return r

    def goods_detail(self, goods_id):
        url = "admin/goods/detail"
        # r = requests.get(url, params={"id": goods_id},
        #                  headers={"x-litemall-admin-token": self.token})
        r = self.send("get", url, params={"id": goods_id})
        return r

    def delete(self, goods_id):
        url = "admin/goods/delete"
        # requests.post(url, json={"id": goods_id}, headers={"x-litemall-admin-token": self.token})
        r = self.send("post", url, json={"id": goods_id})
        return r
